﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;
using System.IO;

namespace Eggplant.Web.Rest.Base
{
	public class XmlSerializer : IHttpSerializer
	{
		#region IHttpSerializer Members

		public object DeserializeValue(string contentType, System.IO.Stream stream, Type type)
		{
			var serializer = new System.Xml.Serialization.XmlSerializer(type);

			object result = serializer.Deserialize(stream);
			return result;
		}

		public void SerializeValue(string contentType, System.IO.Stream stream, object value)
		{
            if (value == null)
                return;

			var serializer = new System.Xml.Serialization.XmlSerializer(value.GetType());
			serializer.Serialize(stream, value);
		}

		#endregion
	}
}